package com.hpeu_12.day1231_homework;

import java.util.Objects;

/**
 * 第八题、Circle类有半径、颜色的属性，写一个测试类，创建两个Circle对象，
 * 判断其颜色是否相等；利用equals方法判断其半径是否相等；利用toString()方法输出其半径。
 */
class Circle {
    double r;
    String yellow;

    public double getR() {
        return r;
    }

    public void setR(double r) {
        this.r = r;
    }

    public String getYellow() {
        return yellow;
    }

    public void setYellow(String yellow) {
        this.yellow = yellow;
    }

    public Circle(double r) {
        this.r = r;
    }

    public Circle(String yellow) {
        this.yellow = yellow;
    }

    public boolean equals(Object o) {
        if (o == null) return true;
        if (o instanceof Circle) {
            Circle c = (Circle) o;
            if (this.r == c.r) {
                return true;
            } else return false;
        } else return false;
    }

    @Override
    public String toString() {
        return "Circle{" +
                "r=" + r +
                "}";
    }
}
    public  class DuoTaiTest7 {
    public static void main(String[] args) {
        Circle c1 = new Circle("黄色");
        Circle c2 = new Circle("黄色");
        boolean b = c1.getYellow() == c2.getYellow();
        System.out.println(b);
        Circle c3 = new Circle(4);
        Circle c4 = new Circle(4);
        System.out.println(c3.equals(c4));
        System.out.println(c3.toString());
        System.out.println(c4.toString());
    }
}
